<?php
/* 	These code was generated using phpCIGen v 0.1.b (21/04/2009)
	#zaqi 		zaqi.smart@gmail.com,http://zenzaqi.blogspot.com, 
	
	+ Module  		: m_setup Controller
	+ Description	: For record controller process back-end
	+ Filename 		: C_m_setup.php
 	+ creator 		: 
 	+ Created on 22/Jan/2012 19:08:53
	
*/

//class of m_setup
class C_m_setup extends CI_Controller {

	//constructor
	function C_m_setup(){
		parent::__construct();
		$this->load->model('m_m_setup', '', TRUE);
		
		
		checkLogin();
	/* 	if(!$_SESSION[SESSION_USERID])
			redirect('c=c_login', 'location', 301); */
	}
	
	//set index
	function index(){
		$this->load->view('main/v_m_setup');
	}
	
	//event handler action
	function get_action(){
		$task = $_POST['task'];
		switch($task){
			case "LIST":
				$this->m_setup_list();
				break;
			case "UPDATE":
				$this->m_setup_update();
				break;
			default:
				echo "{failure:true}";
				break;
		}
	}
	
	//function fot list record
	function m_setup_list(){
		
		$query = isset($_POST['query']) ? @$_POST['query'] : "";
		$start = (integer) (isset($_POST['start']) ? @$_POST['start'] : @$_GET['start']);
		$end = (integer) (isset($_POST['limit']) ? @$_POST['limit'] : @$_GET['limit']);
		$result=$this->m_m_setup->m_setup_list($query,$start,$end);
		echo $result;
	}
	
	//function for update record
	function m_setup_update(){
		//POST variable here
		$setup_id=trim(@$_POST["setup_id"]);
		$setup_ppn=trim(@$_POST["setup_ppn"]);
		$setup_ppn=str_replace("/(<\/?)(p)([^>]*>)", "",$setup_ppn);
		$setup_ppn=str_replace("'", "''",$setup_ppn);
		$setup_kdvo=trim(@$_POST["setup_kdvo"]);
		$setup_kdvo=str_replace("'", "''",$setup_kdvo);
		$setup_kcb5=trim(@$_POST["setup_kcb5"]);
		$setup_kcb5=str_replace("'", "''",$setup_kcb5);
		$setup_kcb6=trim(@$_POST["setup_kcb6"]);
		$setup_kcb6=str_replace("'", "''",$setup_kcb6);
		$setup_kcb7=trim(@$_POST["setup_kcb7"]);
		$setup_kcb7=str_replace("'", "''",$setup_kcb7);
		$setup_ambang=trim(@$_POST["setup_ambang"]);
		$setup_ambang=str_replace("'", "''",$setup_ambang);
		$setup_procmarsitek=trim(@$_POST["setup_procmarsitek"]);
		$setup_procmarsitek=str_replace("'", "''",$setup_procmarsitek);
		$setup_procmme=trim(@$_POST["setup_procmme"]);
		$setup_procmme=str_replace("'", "''",$setup_procmme);
		$setup_procmstruktur=trim(@$_POST["setup_procmstruktur"]);
		$setup_procmstruktur=str_replace("'", "''",$setup_procmstruktur);
		$setup_procm=trim(@$_POST["setup_procm"]);
		$setup_procm=str_replace("'", "''",$setup_procm);
		$setup_ppnjabatan = '';
		$setup_kdvojabatan=trim(@$_POST["setup_kdvojabatan"]);
		$setup_kdvojabatan=str_replace("'", "''",$setup_kdvojabatan);
		$setup_kcb5jabatan=trim(@$_POST["setup_kcb5jabatan"]);
		$setup_kcb5jabatan=str_replace("'", "''",$setup_kcb5jabatan);
		$setup_kcb6jabatan=trim(@$_POST["setup_kcb6jabatan"]);
		$setup_kcb6jabatan=str_replace("'", "''",$setup_kcb6jabatan);
		$setup_kcb7jabatan=trim(@$_POST["setup_kcb7jabatan"]);
		$setup_kcb7jabatan=str_replace("'", "''",$setup_kcb7jabatan);
		$setup_procmarsitekjabatan=trim(@$_POST["setup_procmarsitekjabatan"]);
		$setup_procmarsitekjabatan=str_replace("'", "''",$setup_procmarsitekjabatan);
		$setup_procmmejabatan=trim(@$_POST["setup_procmmejabatan"]);
		$setup_procmmejabatan=str_replace("'", "''",$setup_procmmejabatan);
		$setup_procmstrukturjabatan=trim(@$_POST["setup_procmstrukturjabatan"]);
		$setup_procmstrukturjabatan=str_replace("'", "''",$setup_procmstrukturjabatan);
		$setup_procmjabatan=trim(@$_POST["setup_procmjabatan"]);
		$setup_procmjabatan=str_replace("'", "''",$setup_procmjabatan);
		$setup_pasaljeniskontrak=trim(@$_POST["setup_pasaljeniskontrak"]);
		$setup_pasaljeniskontrak=str_replace("'", "''",$setup_pasaljeniskontrak);
		$setup_pasalnilaikontrak=trim(@$_POST["setup_pasalnilaikontrak"]);
		$setup_pasalnilaikontrak=str_replace("'", "''",$setup_pasalnilaikontrak);
		$setup_pasaltypekonten=trim(@$_POST["setup_pasaltypekonten"]);
		$setup_pasaltypekonten=str_replace("'", "''",$setup_pasaltypekonten);
		$setup_pasalkonten=trim(@$_POST["setup_pasalkonten"]);
		$setup_pasalkonten=str_replace("'", "''",$setup_pasalkonten);
		$setup_cetakspk=trim(@$_POST["setup_cetakspk"]);
		$setup_cetakspk=str_replace("'", "''",$setup_cetakspk);
		$setup_cetakspkcontenttype=trim(@$_POST["setup_cetakspkcontenttype"]);
		$setup_cetakspkcontenttype=str_replace("'", "''",$setup_cetakspkcontenttype);
		$setup_cetakspknilaikontrak=trim(@$_POST["setup_cetakspknilaikontrak"]);

		$setup_cetakIPB=trim(@$_POST["setup_cetakIPB"]);
		$setup_cetakIPB=str_replace("'", "''",$setup_cetakIPB);
		$setup_cetakIPBcontenttype=trim(@$_POST["setup_cetakIPBcontenttype"]);
		$setup_cetakIPBcontenttype=str_replace("'", "''",$setup_cetakIPBcontenttype);
		$setup_cetakIPBnilaikontrak=trim(@$_POST["setup_cetakIPBnilaikontrak"]);
		$setup_cetakIPBnilaikontrak=str_replace("'", "''",$setup_cetakIPBnilaikontrak);
		
		
		$setup_cetakPO=trim(@$_POST["setup_cetakPO"]);
		$setup_cetakPO=str_replace("'", "''",$setup_cetakPO);
		$setup_cetakPOcontenttype=trim(@$_POST["setup_cetakPOcontenttype"]);
		$setup_cetakPOcontenttype=str_replace("'", "''",$setup_cetakPOcontenttype);
		$setup_cetakPOnilaikontrak=trim(@$_POST["setup_cetakPOnilaikontrak"]);
		$setup_cetakPOnilaikontrak=str_replace("'", "''",$setup_cetakPOnilaikontrak);
		
		
		$result = $this->m_m_setup->m_setup_update($setup_cetakspk,$setup_ppn,$setup_kdvo,$setup_kcb5,$setup_kcb6,$setup_kcb7,$setup_procmarsitek,$setup_procmme,$setup_procmstruktur,
			$setup_ppnjabatan,$setup_kdvojabatan,$setup_kcb5jabatan,$setup_kcb6jabatan,$setup_kcb7jabatan,$setup_procmarsitekjabatan,$setup_procmmejabatan,
			$setup_procmstrukturjabatan,$setup_pasaljeniskontrak,$setup_pasaltypekonten,$setup_pasalkonten,$setup_procm,$setup_procmjabatan,$setup_pasalnilaikontrak,$setup_ambang,
			$setup_cetakspkcontenttype,$setup_cetakspknilaikontrak,$setup_cetakIPB, $setup_cetakIPBcontenttype, $setup_cetakIPBnilaikontrak
			,$setup_cetakPO, $setup_cetakPOcontenttype, $setup_cetakPOnilaikontrak
		);
		//echo $result;
		//echo "{success:true}";
	}
	function get_kontenkontrak(){
		$jenis_kontrak = trim(@$_POST['jenis_kontrak']);
		$nilai_kontrak = trim(@$_POST['nilai_kontrak']);
		$type_konten = trim(@$_POST['type_konten']);
		$result = $this->m_m_setup->get_kontenkontrak($jenis_kontrak, $nilai_kontrak,$type_konten);
		echo $result;
	}
	
	// Encodes a SQL array into a JSON formated string
	function JEncode($arr){
		if (version_compare(PHP_VERSION,"5.2","<"))
		{    
			require_once("./JSON.php"); //if php<5.2 need JSON class
			$json = new Services_JSON();//instantiate new json object
			$data=$json->encode($arr);  //encode the data in json format
		} else {
			$data = json_encode($arr);  //encode the data in json format
		}
		return $data;
	}
	
	// Decode a SQL array into a JSON formated string
	function JDecode($arr){
		if (version_compare(PHP_VERSION,"5.2","<"))
		{    
			require_once("./JSON.php"); //if php<5.2 need JSON class
			$json = new Services_JSON();//instantiate new json object
			$data=$json->decode($arr);  //decode the data in json format
		} else {
			$data = json_decode($arr);  //decode the data in json format
		}
		return $data;
	}
	
	
}
?>